<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<link rel="stylesheet" href="../../css/mui.min.css">
<link rel="stylesheet" href="../../css/base.css">
<script src="../../script/api.js" type="text/javascript"></script>
<script src="../../script/jquery.min.js" type="text/javascript"></script>
<script src="../../script/ui.js"></script>
<style>
    .msg_content {
        width: 70%;
        padding-top: 15px;
        padding-left: 10px;
        color: #222222;
        font-size: 18px;
        /*vertical-align: middle;*/
    }

    .companyTeacher {
        border: 1px solid #9AC8E5;
        font-size: 12px;
        color: #9AC8E5;
        line-height: 12px;
        padding: 4px;
        margin-left: 4px;
        vertical-align: middle;
    }

    .mui-pull-left img {
        width: 40px;
    }

    .userIcon {
        width: 20px;
        height: 20px;
        position: absolute;
        top: 50%;
        left: 30px;
        transform: translate(-50%, -50%);
    }
</style>
<body>
<div id='BarAppearance'></div>
<div class="base_navigation_bar base_style_color">
    <a class="base_left_item" href="#" onclick="backClick()"> <img class="base_back_icon"
                                                                   src="../../image/icon_jiantou.png" alt=""> </a>
    <span id="nav_title">成员列表</span>
</div>
<div id="peopleList">
</div>
</body>
</html>
<script>
    var conversationPeopleList;
    var isCanSelected;
    var myRingName;
    apiready = function () {
        initHeaderUI();
        myRingName = $api.getStorage('cfnetringid');
        conversationPeopleList = api.pageParam.conversationPeopleList;
        isCanSelected = api.pageParam.isCanSelected;
        initData();
    };

    function initData() {
        if (isCanSelected) {
            $('#peopleList').append(addItem({nickname: "所有人", identity: [], username: "all"}));
        }

        for (let i = 0; i < conversationPeopleList.length; i++) {
            if (isCanSelected && conversationPeopleList[i].username === myRingName)
                continue;
            $('#peopleList').append(addItem(conversationPeopleList[i]))
        }
    }


    function addItem(item) {
        var name = item.nickname;
        var identity = item.identity;
        var tagItem = "";
        for (let i = 0; i < identity.length; i++) {
            tagItem += "<span class=\"companyTeacher\" >" + identity[i] + "</span>";
        }
        return "<div onclick='peopleClick(" + JSON.stringify(item) + ")' style=\"background: white;border-bottom:1px solid #E2E4E8;height: 4rem;position: relative;line-height: 4rem\">\n" +
            "    <img hidden src=\"../../image/u265.png\" class=\"userIcon\"/>\n" +
            "    <div style=\"margin-left: 20px;\"><span style='font-size: 14px'>" + name + "</span>" + tagItem + "</div>\n" +
            "\n" +
            "</div>"
    }

    function peopleClick(item) {
        if (!isCanSelected)
            return;
        api.sendEvent({
            name: 'selectPeopleFinish',
            extra: {
                people: item,
            }
        });
        backClick();
    }

    function backClick() {
        api.closeWin();
    }
</script>